package com.example.shop.controller;

import com.example.shop.entity.Invertory;
import com.example.shop.service.InvertoryService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName InvertoryController
 * @Description TODO
 * @Author 萍
 * @Date 2025/3/26 10:20
 */
@Controller
@RequestMapping("/inventory")
@Tag(name = "InvertoryController", description = "库存操作的接口")
public class InvertoryController {

    @Autowired
    private InvertoryService invertoryService;

    /**
     * 通过ID查询单条数据
     *
     * @param invertoryid 主键
     * @return 实例对象
     */
    @GetMapping("/{invertoryid}")
    public Invertory queryById(@PathVariable("invertoryid") Integer invertoryid) {
        return invertoryService.queryById(invertoryid);
    }

    /**
     * 新增数据
     *
     * @param invertory 实例对象
     * @return 实例对象
     */
    @PostMapping
    public Invertory insert(@RequestBody Invertory invertory) {
        return invertoryService.insert(invertory);
    }

    /**
     * 修改数据
     *
     * @param invertory 实例对象
     * @return 实例对象
     */
    @PutMapping
    public Invertory update(@RequestBody Invertory invertory) {
        return invertoryService.update(invertory);
    }

    /**
     * 通过主键删除数据
     *
     * @param invertoryid 主键
     * @return 是否成功
     */
    @DeleteMapping("/{invertoryid}")
    public boolean deleteById(@PathVariable("invertoryid") Integer invertoryid) {
        return invertoryService.deleteById(invertoryid);
    }
    @GetMapping
    public List<Invertory> queryAll() {
        return invertoryService.queryAll();
    }

}
